// PlPN.h

static const char* PlPN_Plugin_Name = "PlPN";
static const char* PlPN_Plugin_Version = "0.0.0.0";

// perl sockets will redefine ENOTSOCK
//#undef ENOTSOCK

extern "C" {
	#ifdef PERL_DL
		#include "perl_dl.h"
	#else
		#include <EXTERN.h>
		#include <perl.h>
		#ifdef NEED_XS
			#include "XSUB.h"
		#endif
	#endif
}

// interpreter functions
BOOL init_perl(int* argc, char*** argv);
BOOL term_perl();
BOOL create_interpreter(int argc, char** argv);
BOOL destroy_interpreter();
BOOL cycle_interpreter(int argc, char** argv);
void run_script(char* filename);

// menu functions

void menu_cycle_interpreter(extensions::cookie_t /*cookie*/);
void menu_get_dll(extensions::cookie_t /*cookie*/);
void menu_show_help(extensions::cookie_t /*cookie*/);

// hacks because I can't get the C/C++ external symbols to work right
// either it works in C and not in C++ or vice versa
// but for some reason, these function definitions work just fine

static extensions::IPN* my_pn;
static PerlInterpreter* my_perl;

extern "C" extensions::IPN* get_my_pn();
extern "C" PerlInterpreter* get_my_perl();

#ifdef PERL_DL

extern "C" perlfunc_sys_init3 my_Perl_sys_init3;
extern "C" perlfunc_sys_term my_Perl_sys_term;
extern "C" perlfunc_alloc my_perl_alloc;
extern "C" perlfunc_construct my_perl_construct;
extern "C" perlfunc_destruct my_perl_destruct;
extern "C" perlfunc_free my_perl_free;
extern "C" perlfunc_parse my_perl_parse;
extern "C" perlfunc_run my_perl_run;
extern "C" perlfunc_Perl_Ierrgv_ptr my_Perl_Ierrgv_ptr;
extern "C" perlfunc_Perl_call_argv my_Perl_call_argv;
extern "C" perlfunc_Perl_eval_pv my_Perl_eval_pv;
extern "C" perlfunc_Perl_gv_add_by_type my_Perl_gv_add_by_type;
extern "C" perlfunc_Perl_sv_2bool my_Perl_sv_2bool;
extern "C" perlfunc_Perl_sv_2pv_flags my_Perl_sv_2pv_flags;
extern "C" perlfunc_Perl_sv_2bool my_Perl_sv_2bool;
extern "C" perlfunc_Perl_sv_2pv_flags my_Perl_sv_2pv_flags;

#ifdef NEED_XS

extern "C" perlfunc_Perl_av_fetch my_Perl_av_fetch;
extern "C" perlfunc_Perl_av_len my_Perl_av_len;
extern "C" perlfunc_Perl_av_store my_Perl_av_store;
extern "C" perlfunc_Perl_call_list my_Perl_call_list;
extern "C" perlfunc_Perl_call_method my_Perl_call_method;
extern "C" perlfunc_Perl_call_pv my_Perl_call_pv;
extern "C" perlfunc_Perl_call_sv my_Perl_call_sv;
extern "C" perlfunc_Perl_croak_nocontext my_Perl_croak_nocontext;
extern "C" perlfunc_Perl_croak_xs_usage my_Perl_croak_xs_usage;
extern "C" perlfunc_Perl_free_tmps my_Perl_free_tmps;
extern "C" perlfunc_Perl_get_context my_Perl_get_context;
extern "C" perlfunc_Perl_get_hv my_Perl_get_hv;
extern "C" perlfunc_Perl_get_sv my_Perl_get_sv;
extern "C" perlfunc_Perl_gv_stashpv my_Perl_gv_stashpv;
extern "C" perlfunc_Perl_hv_common_key_len my_Perl_hv_common_key_len;
extern "C" perlfunc_Perl_Iamagic_generation_ptr my_Perl_Iamagic_generation_ptr;
extern "C" perlfunc_Perl_Icurpad_ptr my_Perl_Icurpad_ptr;
extern "C" perlfunc_Perl_Idirty_ptr my_Perl_Idirty_ptr;
extern "C" perlfunc_Perl_Imarkstack_max_ptr my_Perl_Imarkstack_max_ptr;
extern "C" perlfunc_Perl_Imarkstack_ptr_ptr my_Perl_Imarkstack_ptr_ptr;
extern "C" perlfunc_Perl_Iop_ptr my_Perl_Iop_ptr;
extern "C" perlfunc_Perl_Iscopestack_ix_ptr my_Perl_Iscopestack_ix_ptr;
extern "C" perlfunc_Perl_Istack_base_ptr my_Perl_Istack_base_ptr;
extern "C" perlfunc_Perl_Istack_sp_ptr my_Perl_Istack_sp_ptr;
extern "C" perlfunc_Perl_Istack_max_ptr my_Perl_Istack_max_ptr;
extern "C" perlfunc_Perl_Isv_no_ptr my_Perl_Isv_no_ptr;
extern "C" perlfunc_Perl_ISv_ptr my_Perl_ISv_ptr;
extern "C" perlfunc_Perl_Isv_yes_ptr my_Perl_Isv_yes_ptr;
extern "C" perlfunc_Perl_Isv_undef_ptr my_Perl_Isv_undef_ptr;
extern "C" perlfunc_Perl_Itmps_floor_ptr my_Perl_Itmps_floor_ptr;
extern "C" perlfunc_Perl_Itmps_ix_ptr my_Perl_Itmps_ix_ptr;
extern "C" perlfunc_Perl_IXpv_ptr my_Perl_IXpv_ptr;
extern "C" perlfunc_Perl_Iunitcheckav_ptr my_Perl_Iunitcheckav_ptr;
extern "C" perlfunc_Perl_markstack_grow my_Perl_markstack_grow;
extern "C" perlfunc_Perl_mg_set my_Perl_mg_set;
extern "C" perlfunc_Perl_newRV my_Perl_newRV;
extern "C" perlfunc_Perl_newRV_noinc my_Perl_newRV_noinc;
extern "C" perlfunc_Perl_newSV my_Perl_newSV;
extern "C" perlfunc_Perl_newSViv my_Perl_newSViv;
extern "C" perlfunc_Perl_newSVpv my_Perl_newSVpv;
extern "C" perlfunc_Perl_newSVpvn my_Perl_newSVpvn;
extern "C" perlfunc_Perl_newSVsv my_Perl_newSVsv;
extern "C" perlfunc_Perl_newSVuv my_Perl_newSVuv;
extern "C" perlfunc_Perl_newXS my_Perl_newXS;
extern "C" perlfunc_Perl_newXS_flags my_Perl_newXS_flags;
extern "C" perlfunc_Perl_newSV_type my_Perl_newSV_type;
extern "C" perlfunc_Perl_pop_scope my_Perl_pop_scope;
extern "C" perlfunc_Perl_push_scope my_Perl_push_scope;
extern "C" perlfunc_Perl_save_int my_Perl_save_int;
extern "C" perlfunc_Perl_stack_grow my_Perl_stack_grow;
extern "C" perlfunc_Perl_sv_2iv_flags my_Perl_sv_2iv_flags;
extern "C" perlfunc_Perl_sv_2mortal my_Perl_sv_2mortal;
extern "C" perlfunc_Perl_sv_2uv_flags my_Perl_sv_2uv_flags;
extern "C" perlfunc_Perl_sv_bless my_Perl_sv_bless;
extern "C" perlfunc_Perl_sv_catpvn_flags my_Perl_sv_catpvn_flags;
extern "C" perlfunc_Perl_sv_derived_from my_Perl_sv_derived_from;
extern "C" perlfunc_Perl_sv_free my_Perl_sv_free;
extern "C" perlfunc_Perl_sv_isobject my_Perl_sv_isobject;
extern "C" perlfunc_Perl_sv_len my_Perl_sv_len;
extern "C" perlfunc_Perl_sv_mortalcopy my_Perl_sv_mortalcopy;
extern "C" perlfunc_Perl_sv_newmortal my_Perl_sv_newmortal;
extern "C" perlfunc_Perl_sv_setiv my_Perl_sv_setiv;
extern "C" perlfunc_Perl_sv_setpv my_Perl_sv_setpv;
extern "C" perlfunc_Perl_sv_setref_pv my_Perl_sv_setref_pv;
extern "C" perlfunc_Perl_sv_setsv_flags my_Perl_sv_setsv_flags;
extern "C" perlfunc_Perl_sv_setuv my_Perl_sv_setuv;
extern "C" perlfunc_Perl_uvuni_to_utf8_flags my_Perl_uvuni_to_utf8_flags;
extern "C" perlfunc_Perl_warn_nocontext my_Perl_warn_nocontext;

#endif	// NEED_XS
#endif	// PERL_DL